<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2016/10/9
 * Time: 22:18
 */
header("Content-type:text/html;charset=utf-8");
//获取文件后缀的函数，参数$path表示文件名称
function getFileExt($path){
    //获取文件后缀
    $ext = substr($path,strrpos($path,'.')+1);
    //返回文件后缀
    return $ext;
}
//保存文件路径
$path = 'C:\images\apple.jpg';
//调用函数getFileExt()获取文件后缀
$ext =getFileExt($path);
//输出获取文件的后缀
echo "<p>文件路径：$path </p>";
echo "<p>文件后缀：$ext </p>";